import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;




public class Test {
public static void main(String[] argv) {
		
		
		System.out.println("-------- PostgreSQL "
				+ "JDBC Connection Testing ------------");
 
		try { // Initialisierung Treiber
 
			Class.forName("org.postgresql.Driver");
			
		} catch (ClassNotFoundException e) {
 
			System.out.println("Where is your PostgreSQL JDBC Driver? "
					+ "Include in your library path!");
			e.printStackTrace();
			return;
 
		}
 
		System.out.println("PostgreSQL JDBC Driver Registered!");
 
		Connection connection = null;
		
		
		try { // Verbindungsaufbau zu Datenbank
 
			connection = DriverManager.getConnection(
					"jdbc:postgresql://localhost:5432/CATDAT", "postgres",
					"dast");
			
			Statement statement = connection.createStatement();
			
			String selectquery = "SELECT * FROM iket.event_earthquake";
			ResultSet result = statement.executeQuery(selectquery);	
			
				
			
				while (result.next()) //interner Cursor wird auf die erste Zeile gesetzt
				{   
					
					Statement statement2 = connection.createStatement();
					Float depth = result.getFloat(7);	
					
										
					
					String update = "UPDATE iket.event_earthquake SET depth=" + "'16,0' WHERE depth LIKE '16'";
					statement2.executeUpdate(update);	
					
								
				
				} 
			
				result.close();	
				statement.close();
				connection.close();
				
				
		} catch (SQLException e) {
 
			System.out.println("Connection Failed! Check output console");
			e.printStackTrace();
			return;
			
			
		}
	
		
		if (connection != null) {
			System.out.println("You made it, take control your database now!");
			
			
		} 
		else {
			System.out.println("Failed to make connection!");
		}
	}
}
